<template>
  <view class="h">
    <!-- 专辑开始 -->
    <view class="album_bg">
      <image mode="widthFix" :src="album.cover"></image>
      <view class="album_info">
        <view class="album_name">{{ album.name }}</view>
        <view class="album_btn">关注专辑</view>
      </view>
    </view>

    <!-- 专辑结束 -->

    <!-- 作者 开始 -->
    <view class="album_author">
      <view class="author_info">
        <image mode="widthFix" :src="album.user.avatar"></image>
        <view class="author_name">{{ album.user.name }}</view>
      </view>
      <view class="author_desc">
        <text class="h">
          {{ album.desc }}
        </text>
      </view>
    </view>
    <!-- 作者 结束 -->

    <!-- 列表  开始 -->
    <view class="album_list">
      <view class="list_item" v-for="(item,index) in wallpaper" :key="item.id">
        <goDetail :list="wallpaper" :index="index">
          <image
          mode="widthFix"
          :src="item.thumb + item.rule.replace('$<Height>', 360)"
        ></image>
        </goDetail>
        
      </view>
    </view>

    <!-- 列表  结束 -->
  </view>
</template>

<script>
import goDetail from "@/components/goDetail"
export default {
  data() {
    return {
      //请求参数
      params: {
        limit: 30,
        order: "new",
        skip: 0,
        first: 1,
      },

      //详情id
      id: -1,
      album: {},
      wallpaper: [],
      hasMore: true,
    };
  },
  methods: {
    getList() {
      this.request({
        url: `http://157.122.54.189:9088/image/v1/wallpaper/album/${this.id}/wallpaper`,
        data: this.params,
      }).then((result) => {
        console.log(result);
        //专辑介绍
        if (Object.keys(this.album).length === 0) {
          this.album = result.res.album;
        }
        if (result.res.wallpaper.length === 0) {
          this.hasMore = false;
           uni.showToast({
        title: "没有数据啦",
        icon: "none",
      });
          return;
        }

        //壁纸
        this.wallpaper = [...this.wallpaper ,...result.res.wallpaper];
        console.log(this.album);
      });
    },
  },
  onLoad(options) {
    this.id = "5dea515de7bce73981faf1a9";
    // this.id = options.id
    console.log(this.id)
    this.getList();
  },
  onReachBottom() {
    // console.log("到底啦")
   
    if (this.hasMore) {
       this.params.first = 0
      this.params.skip += this.params.limit;
      this.getList();
    } else {
      uni.showToast({
        title: "没有数据啦",
        icon: "none",
      });
    }
  },
  components:{
    goDetail
  }
};
</script>

<style lang="scss" scoped>
.album_bg {
  position: relative;
  iamge {
  }

  .album_info {
    position: absolute;
    width: 100%;
    left: 0;
    bottom: 0;
    display: flex;
    justify-content: space-between;
    height: 80rpx;
    align-items: center;
    color: #ffffff;
    padding: 0 15rpx;
    .album_name {
      font-size: 40rpx;
    }

    .album_btn {
      background-color: $color;
      width: 152rpx;
      height: 60rpx;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius: 10rpx;
    }
  }
}
.album_author {
  padding: 10rpx;
  .author_info {
    display: flex;
    padding: 10rpx 0;
    image {
      width: 50rpx;
    }

    .author_name {
      color: #000;
      font-weight: 500;
      margin-left: 10rpx;
    }
  }

  .author_desc {
  }
}
.album_list {
  display: flex;
  flex-wrap: wrap;
  .list_item {
    width: 33.33%;
    border: 5rpx solid #ffffff;
    image {
    }
  }
}
</style>
